﻿using AutoMapper;
using DataServer.ApplicationLib.Entities;
using DataServer.CommonLib.Models.DataConfig;

namespace Config.WebApi.Mappers
{
    public class DataConfigProfile : Profile
    {
        public DataConfigProfile()
        {
            CreateMap<DataConfigEditRequestDto, DataConfigEntity>();

            CreateMap<DataConfigEntity, DataConfigInfoResponseDto>()
                .ForMember(desc => desc.Key, opt => opt.MapFrom(src => src.Id));

            CreateMap<ConfigFieldEditRequestDto, ConfigFieldEntity>();

            CreateMap<ConfigFieldEntity, ConfigFieldInfoResponseDto>()
                .ForMember(desc => desc.Key, opt => opt.MapFrom(src => src.Id));

            CreateMap<ConfigRuleEditRequestDto, ConfigRuleEntity>();

            CreateMap<ConfigRuleEntity, ConfigRuleInfoResponseDto>()
                .ForMember(desc => desc.Key, opt => opt.MapFrom(src => src.Id));
        }
    }
}